//tab.js
//获取应用实例
const app = getApp()

Component({
  properties:{
    index:{
      type:String
    }
  },
  data: {
    idx:'',//默认激活下标
    tab:[
      { name:'首页',
        def:'/common/img/sy2.png',
        active:'/common/img/sy1.png',
      },
      {
        name: '发现',
        def: '/common/img/fax2.png',
        active: '/common/img/fax1.png',
      },
      {
        name: '发布',
        def: '',
        active: '',
      },
      {
        name: '狗牌',
        def: '/common/img/gp.png',
        active: '/common/img/gp1.png',
      },
      {
        name: '我的',
        def: '/common/img/wd2.png',
        active: '/common/img/wd1.png',
      },
    ]
  },
  attached:function(){
    this.setData({ idx: this.data.index })
  },
  methods: {
    go(){
      wx.navigateTo({
        url: '../commit/commit'
      })
    },
    onTap:  function(e) {
     
      let i = e.currentTarget.dataset.index;
      console.log(i)  
      if (this.data.index != i){
        if (i == 0) {
          wx.reLaunch({
            url: '../index/index'
          })
        }else if(i == 1){
          wx.reLaunch({
            url: '../found/found'
          })
        }else if( i == 2){
          wx.reLaunch({
            url: '../commit/commit'
          })
        }else if (i == 3) {
          wx.reLaunch({
            url: '../dogCard/dogCard'
          })
        } else if (i == 4) {
          wx.reLaunch({
            url: '../my/my'
          })
        }
      }
      
    }

  }
  
})
